from django.db import models

# Create your models here.

class Publish(models.Model):
    name = models.CharField(max_length=10,verbose_name='作者')
    city = models.CharField(max_length=10,verbose_name='城市')
    def __str__(self):
        return self.name
    class Meta:
        db_table = 'publish'




class Book(models.Model):
    bookname = models.CharField(max_length=10,verbose_name='书名')
    price = models.DecimalField(max_digits=8,decimal_places=2,verbose_name='价格')
    number = models.IntegerField(verbose_name='库存')
    publish = models.ForeignKey(to=Publish,on_delete=models.CASCADE)
    def __str__(self):
        return self.bookname
    class Meta:
        db_table = 'book'